import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class TabPanel  extends JTabbedPane {

    private static final int JFRAME_WIDTH = 600;
    private static final int JFRAME_HEIGHT= 400;
    private TabPanel(){


        URL url1 = TabPanel.class.getResource("images/shouye.png");
        URL url2 = TabPanel.class.getResource("images/wode.png");
        Icon icon1 = new ImageIcon(url1);
        Icon icon2 = new ImageIcon(url2);
        //窗口-顶层面板
        JFrame jFrame = new JFrame("tab页签");
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setSize(JFRAME_WIDTH,JFRAME_HEIGHT);
        jFrame.setVisible(true);
        //面板
        JPanel jPanel = new JPanel();
        jFrame.setContentPane(jPanel);
        setLayout(new BorderLayout());
        //子面板
        JPanel jPanel1 = new JPanel();
        JPanel jPanel2 = new JPanel();
        jPanel1.setLayout(new BorderLayout());
        addTab("panel1",icon1,jPanel1);
        setEnabledAt(0,true);
        setTitleAt(0,"会计科目");
        addTab("panel2",icon2,jPanel2);
        setEnabledAt(1,true);
        setTitleAt(1,"结算策略");
        setPreferredSize(new Dimension(500,200));
        setTabPlacement(JTabbedPane.LEFT);
        setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        jPanel.add("Center",this);
        setVisible(true);
    }
    public static void main(String[] args) throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        UIManager.setLookAndFeel(
                UIManager.getCrossPlatformLookAndFeelClassName());
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        new TabPanel();
    }


}
